CREATE TABLE [dbo].[TTIDEN_CNTA]
(
[CO_EMPR] [dbo].[TD_VC_002] NOT NULL,
[NU_ANNO] [dbo].[TD_IN_004_ANNO] NOT NULL CONSTRAINT [DF__TTIDEN_CN__NU_AN__4DE98D56] DEFAULT (datepart(year,getdate())),
[NU_CNTB_EMPR] [dbo].[TD_IN_001_CONT] NOT NULL,
[ID_CNTA] [dbo].[TD_VC_003] NOT NULL,
[CO_CNTA_EMPR] [dbo].[TD_VC_020_CNTA] NOT NULL,
[CO_USUA_CREA] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_CREA] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TTIDEN_CN__FE_US__51BA1E3A] DEFAULT (getdate()),
[CO_USUA_MODI] [dbo].[TD_VC_008_USUA] NOT NULL,
[FE_USUA_MODI] [dbo].[TD_DT_001_SIST] NOT NULL CONSTRAINT [DF__TTIDEN_CN__FE_US__52AE4273] DEFAULT (getdate())
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TTIDEN_CNTA] ADD CONSTRAINT [CK__TTIDEN_CN__CO_CN__50C5FA01] CHECK (([CO_CNTA_EMPR]>='0' AND [CO_CNTA_EMPR]<='99999999999999999999'))
GO
ALTER TABLE [dbo].[TTIDEN_CNTA] ADD CONSTRAINT [CK__TTIDEN_CN__NU_AN__4EDDB18F] CHECK (([NU_ANNO]>=(0)))
GO
ALTER TABLE [dbo].[TTIDEN_CNTA] ADD CONSTRAINT [CK__TTIDEN_CN__NU_CN__4FD1D5C8] CHECK (([NU_CNTB_EMPR]>=(1) AND [NU_CNTB_EMPR]<=(99)))
GO
ALTER TABLE [dbo].[TTIDEN_CNTA] ADD CONSTRAINT [TTIDEN_CNT_271471421] PRIMARY KEY CLUSTERED  ([CO_EMPR], [NU_ANNO], [NU_CNTB_EMPR], [ID_CNTA], [CO_CNTA_EMPR]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[TTIDEN_CNTA] ADD CONSTRAINT [FK1_TMPLAN_ANNO_A_TTIDEN_CNTA] FOREIGN KEY ([CO_EMPR], [CO_CNTA_EMPR]) REFERENCES [dbo].[TMPLAN_ANNO] ([CO_EMPR], [CO_CNTA_EMPR])
GO
ALTER TABLE [dbo].[TTIDEN_CNTA] ADD CONSTRAINT [FK1_TTCNTB_EMPR_A_TTIDEN_CNTA] FOREIGN KEY ([CO_EMPR], [NU_CNTB_EMPR]) REFERENCES [dbo].[TTCNTB_EMPR] ([CO_EMPR], [NU_CNTB_EMPR])
GO
